<?php 


$url = "https://home.rabbitpre.com/api/workbench/marketing/mydata/formList";

// echo json_encode($_GET,JSON_UNESCAPED_UNICODE);


$parmas = [
	'appid'=>$_GET['appid'],
	'appType'=>'onepage',
	'pageNo'=>'1',
	'pageSize'=>'5000',
	'startTime'=>$_GET['starDateTime'],
	'endTime'=>$_GET['endDateTime'],
	'channels'=>'',
	'deptIds'=>''
];

if($_GET['Cookie']!==""){
	file_put_contents('cookie.txt',$_GET['Cookie']);
}

$Cookie = file_get_contents('cookie.txt');
$header = [

	"Cookie:".$Cookie

];

$res = php_do_Url_GET($url,$parmas,$header);


$url_data = "https://home.rabbitpre.com/api/workbench/marketing/fibodata/viewData/getBaseData";

$parmas_data = [
	'appId'=>$_GET['appid'],
	'appType'=>'onepage',
	'interval'=>'HOUR',
	'startTime'=>$_GET['starDateTime'],
	'endTime'=>$_GET['endDateTime'],
	'projectId'=>'',
	'subProjectId'=>''
];

$res_data = php_do_Url_GET($url_data,$parmas_data,$header);




$url_index = "https://home.rabbitpre.com/api/workbench/marketing/myapp/getDataVewCount";

$parmas_index = ['appIds'=>$_GET['appid']];

$res_index = php_do_Url_GET($url_index,$parmas_index,$header);


$url_list = "https://home.rabbitpre.com/api/workbench/marketing/myapp/list";

$parmas_list = [
	
	'appContentSource'=> "",
	'keyword'=> $_GET['keyword'],
	'pageNo'=> '1',
	'pageSize'=> '30',
	'queryType'=> '0'
];


// $res_list = php_do_url_POST($url_list,$parmas_list,$header);

// var_dump(json_decode(file_get_contents('list.json')));

$res_list = json_decode(file_get_contents('list.json'));

if($res['success']){
	
	$res['fenxi'] = $res_data;

	$res['index'] = $res_index;

	$res['list'] = $res_list;

	echo json_encode($res,JSON_UNESCAPED_UNICODE);

}else{

	echo json_encode($res,JSON_UNESCAPED_UNICODE);


}





function php_do_Url_GET($url,$params=[],$headers=[]){ //Get get

		$url = "{$url}?" . http_build_query ($params);
		// echo $url;
		$ch = curl_init ();
		curl_setopt ( $ch, CURLOPT_URL, $url );
		curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
		curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
		curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 );
		//curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params );
		curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_SSLVERSION, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


		$json_string = curl_exec ( $ch );

		$data = json_decode($json_string, true);

		curl_close ( $ch );

		return $data;
	}

function  php_do_url_POST($url,$params,$headers){ //POST get

			$ch = curl_init ();

			curl_setopt ( $ch, CURLOPT_URL, $url );
			curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
			curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
			curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params );
			curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
			curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 );
			curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
			curl_setopt($ch, CURLOPT_SSLVERSION, false);
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

			$json_string = curl_exec ( $ch );
			$data = json_decode($json_string, true);
			curl_close ( $ch );
			return $data;
	}
 ?>
